package com.huahua.bigdata.spark.rdd.operate;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

public class Spark06_Operate_Transform_distinct {
    public static void main(String[] args) {
        SparkConf conf = new SparkConf();
        conf.setMaster("local");
        conf.setAppName("spark");
        JavaSparkContext jsc = new JavaSparkContext(conf);
        List<Integer> datas = Arrays.asList(1, 1, 1, 1, 2, 3, 2, 4);
        JavaRDD<Integer> rdd = jsc.parallelize(datas,3);
        // TODO distinct 去重
        //      是分布式去重, 采用了分组+shuffle的处理方式
        rdd.distinct().collect().forEach(System.out::println);

        jsc.close();
    }
}
